package com.rtx.express.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.rtx.edi.model.api.bo.ApiMappingInfoBo;
import com.rtx.edi.platform.baseinfo.service.PlApiService;
import com.rtx.express.handle.ConfigExpress;
import com.rtx.express.service.impl.DYExpressAPI;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

@Api(tags = {"快递接口"})
@RestController
@RequestMapping("/v1/edi/express")
public class ExpressController {
	
	Logger log = LoggerFactory.getLogger(this.getClass());
	
	@Autowired
	ConfigExpress expressTaskHandle;
	
	
	@Autowired
	DYExpressAPI dyExpressAPI;
	
	@Autowired
	PlApiService plApiService;
	
	/**
	 * 功能调用获取快递单号
	 * @param bodyStr
	 * @return
	 */
    @ApiOperation(value = "获取快递单号", notes = "获取快递单号")
	@PostMapping(value = "/querymailno")
	public String expressApi(@RequestBody String bodyStr) {
		JSONObject wmsRequest = JSON.parseObject(bodyStr);
		String mappingCode = wmsRequest.get("apiMappingCode")+"";
		
		ApiMappingInfoBo bo = plApiService.getApiMappingInfo(mappingCode);
		
		return expressTaskHandle.handleExpress(wmsRequest.getString("whseid"),bodyStr,bo);
	}
	
	
	
	@GetMapping(value = "/getdyparameter")
	public String getdyParameter() {
		return dyExpressAPI.getparameter();
	}
	
	
	@GetMapping(value = "/getdytemplatelist")
	public String getdyTemplateList() {
		return dyExpressAPI.dyTemplateList();
	}
}
